﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace KJSyncXP.Extensions
{
    public class AppConfig: INotifyPropertyChanged
    {

        public string OracleMesConnectionString { get; set; }

        public string SqliteConnectionString { get; set; }

        public string AccessConnectionString { get; set; }

        public string AccessConnectionString2 { get; set; }

        public string IdFileDataDirectory { get; set; } 

        public string DetectionMachineNo { get; set; }

        public int SyncTime { get; set; }

        public int StrandChangeShowTip { get; set; }

        public int StartWorkCheckShowTip { get; set; }

        public int PrecisionCheckShowTip { get; set; }

        public string ServicePhone {  get; set; }
        public string comport { get; set; }

        ///<summary>
        ///当前操作员
        ///</summary>
        // 关键：当前登录用户（字符串类型，因为你在LoginViewModel中存的是user.Username）
        [JsonIgnore]
        private string _currentUser;
        [JsonIgnore]
        public string CurrentUser
        {
            get => _currentUser;
            set
            {
                if (_currentUser != value) // 避免重复赋值
                {
                    _currentUser = value;
                    OnPropertyChanged(); 
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// 触发属性变化通知（自动获取属性名，无需手动传参）
        /// </summary>
        private void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    // 中间类，匹配JSON最外层结构
    public class ConfigWrapper
    {
        public AppConfig AppConfig { get; set; }
    }
}
